Source: TwinCAT Quick Start 2.8 from www.beckhoff.com or ftp://ftp.beckhoff.com/Software/TwinCAT/InfoSystem |
Five different languages conforming to IEC 61131-3 are available for creating
a PLC program using TwinCAT PLC.
A list of variable types in compair to other laguages.
The instruction list is very similar to the STEP5 programming language. Every instruction begins in a new line and contains one operator and one or several operands. An instruction may be preceded by a label, followed by a colon. A comment must be the last element in one line.
Example:
label | operator | operand | comment |
---|---|---|---|
Start: | LD | Basin_level | (* Load level *) |
GE | 13 | (* Limit reached? *) | |
JMPC | Pump_on | ||
R | Pump_control | (* Pump off *) | |
JMP | End | ||
Pump_on: | S | S Pump_control | (* Pump on *): |
End: |
In the case of this programming language, we also speak of a higher-level programming language because it is not "machine-oriented" commands that are used. Instead, power command strings can be created by way of abstract commands. From the area of the PC, Basic, PASCAL and C are comparable higher-level programming languages.
Example:
operator | operand | comment |
---|---|---|
CASE Temperatur_furnace OF | (* control heating output *) | |
60..99: Heating := 80; | (* 80% *) | |
100..149: Heating := 60; | (* 60% *) | |
150..199: Heating := 35; | (* 35% *) | |
200..250: Heating := 10; | (* 10% *) | |
ELSE Alarm := TRUE; | (* Set alarm *) | |
END_CASE; |
The basic idea behind PLC programming with the function block diagram is that the program is structured in function-oriented logical sequence cascades (networks). Within one network, the executed direction is always from left to right. All input values must always have been generated before execution of a function block. Evaluation of a network is not concluded until the output values of all elements have been calculated.
Example:
The representation of logical sequences in the form of the ladder diagram originates from the area of electrotechnical plant engineering. This mode of representation is particularly suitable for implementing relay switching operations in PLC programs. Processing is limited to the Boolean signals 1 and 2.
The sequential function chart is expedient wherever sequencer program-ming is necessary. Complex tasks are split into clearly arranged portions of program (steps). The sequence between these steps is then defined graphically. The steps themselves are created in a different programming language (ST, IL,…) or can also be represented in SFC again.
Example:
SFC programs essentially consist of steps, transitions and their links. Each step is assigned a set of commands. These commands are executed when the step is active. A transition must be fulfilled to ensure that the next step is executed. The steps and the transitions can be formulated in any chosen language.